#pragma once

namespace Base { namespace CmdFwk {

    class Command;
    class CmdMgr;

    // CmdDef intends to define a command.Its instance will
    // be holded by CmdMgr. In details, invoke CmdMgr::addCmdDef()
    // to register the command definition. For example:
    // Base::CmdFwk::CmdMgr::get()->addCmdDef(new MyCmdDef());

    class CmdDef
    {
        friend class CmdMgr;

    public:
        CmdDef(const std::string& name);

    protected:
        ~CmdDef();

    public:
        const void* id() const;
        
        void environments(const std::vector<const void*>&);
        const std::vector<const void*>& environments() const;
        bool isInEnv(const void* envId) const;

    protected:
        virtual Command* createCmd() = 0;

    private:
        const void*                 m_id;
        std::vector<const void*>    m_environments;
    };

}}